package com.market.goods.web;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.market.goods.constance.*;
import com.market.goods.dao.es.*;
import com.market.goods.dao.mapper.CategoryBrandMapper;
import com.market.goods.dao.mapper.MarketBrandMapper;
import com.market.goods.dao.mongo.MarketGoodsParams;
import com.market.goods.dao.mongo.MarketGoodsType;
import com.market.goods.dao.po.CategoryBrandPO;
import com.market.goods.dao.po.MarketBrandPO;
import com.market.goods.producer.KafkaClusterProducer;
import com.market.goods.service.MarketGoodsService;
import com.market.goods.service.MongoDbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Slf4j
@Api(tags = "mocker数据相关服务")
@RestController
@RequestMapping("/mockData")
public class MockDataController {

    @Autowired
    CategoryBrandMapper categoryBrandMapper;

    @Autowired
    MarketBrandMapper marketBrandMapper;

    @Autowired
    KafkaClusterProducer kafkaClusterProducer;

    @Autowired
    MongoDbService mongoDbService;

    @Autowired
    MarketGoodsService marketGoodsService;

    @ApiOperation("mock品牌数据")
    @GetMapping("addBrand")
    public void addBrand() {
        List<String> brandNameS = Lists.newArrayList();
        for (String brandName : MarketGoodsMockData.clothingBrand1) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.mobilePhoneBrand2) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.computerBrand3) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.airConditioner4) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.iceBoxBrand5) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.tvBrand6) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }

        for (String brandName : MarketGoodsMockData.watchingBrand7) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.dianchiluBrand8) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.weiboluBrand9) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.youyanjiBrand10) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.yundongxieBrand11) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.pixieBrand12) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.tongzhuangBrand13) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.lingshiBrand14) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.dianfengshangBrand15) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }
        for (String brandName : MarketGoodsMockData.ledBrand16) {
            if (!brandNameS.contains(brandName)) {
                brandNameS.add(brandName);
            }
        }

        for (String brandName : brandNameS) {
            MarketBrandPO marketBrandPO = new MarketBrandPO();
            String setBrandId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
            marketBrandPO.setBrandId(setBrandId);
            marketBrandPO.setBrandName(brandName);
            marketBrandMapper.insertSelective(marketBrandPO);
        }

    }

    @ApiOperation("mock小米手机品类品牌数据")
    @GetMapping("addXiaomiShoujiCategoryBrand")
    public void addXiaomiShoujiCategoryBrand() throws IOException {
        MarketBrandPO queryMarketBrandPO = new MarketBrandPO();
        queryMarketBrandPO.setBrandId("754005757099245568e83100108e764f1297fc6c3c13ea2129");
        Date nowTime = new Date();
        List<MarketBrandPO> marketBrandPOS = marketBrandMapper.select(queryMarketBrandPO);
        for (MarketBrandPO marketBrandPO : marketBrandPOS) {
            String brandName = marketBrandPO.getBrandName();
            String brandId = marketBrandPO.getBrandId();
            for (int k = 0; k < BrandGoodsTypeMockData.brandmodel.length; k++) {
                if (k != 0) {
                    continue;
                }
                String categoryId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String categoryName = brandName + BrandGoodsTypeMockData.brandmodel[k];
                CategoryBrandPO categoryBrandPO = new CategoryBrandPO();
                categoryBrandPO.setCategoryId(categoryId);
                categoryBrandPO.setCategoryName(categoryName);
                categoryBrandPO.setBrandId(brandId);
                categoryBrandPO.setBrandName(brandName);
                String goodsTypeId1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String goodsTypeName1 = BrandGoodsTypeMockData.brandmodel[k];
                for (int j = 0; j < BrandGoodsTypeMockData.modelGoodsshouji1.length; j++) {
                    String goodsTypeId2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String goodsTypeName2 = BrandGoodsTypeMockData.modelGoodsshouji1[j];
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    for (int n = 0; n < BrandGoodsTypeMockData.modelGoodsshouji11.length; n++) {
                        String goodsTypeId3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String goodsTypeName3 = BrandGoodsTypeMockData.modelGoodsshouji11[n];
                        categoryBrandPO.setGoodsTypeName(goodsTypeName3);
                        categoryBrandPO.setGoodsTypeId(goodsTypeId3);
                        categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                        categoryBrandPO.setSuperiorTypeId(goodsTypeId2);
                        log.info("addCategoryBrand3={}", categoryBrandPO);
                        CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                        BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                        categoryBrandDocument.setVersion("1");
                        categoryBrandDocument.setCreatedTime(nowTime);
                        categoryBrandDocument.setUpdateTime(nowTime);
                        //发送kafka
                        String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                        kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                        marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);


                    }
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    log.info("addCategoryBrand2={}", categoryBrandPO);
                    categoryBrandMapper.insertSelective(categoryBrandPO);
                    CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                    BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                    categoryBrandDocument.setVersion("1");
                    categoryBrandDocument.setCreatedTime(nowTime);
                    categoryBrandDocument.setUpdateTime(nowTime);
                    //发送kafka
                    String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                    kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                    marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
                    addPhoneGoodsDocument(categoryBrandDocument);

                }
                categoryBrandMapper.insertSelective(categoryBrandPO);
                categoryBrandPO.setSuperiorTypeId(null);
                categoryBrandPO.setGoodsTypeId(goodsTypeId1);
                categoryBrandPO.setGoodsTypeName(goodsTypeName1);
                categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                log.info("addCategoryBrand1={}", categoryBrandPO);
                CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                categoryBrandDocument.setVersion("1");
                categoryBrandDocument.setCreatedTime(nowTime);
                categoryBrandDocument.setUpdateTime(nowTime);
                //发送kafka
                String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
            }
        }

    }

    @ApiOperation("mock小米手机卡品类品牌数据")
    @GetMapping("addXiaomiShoujiKaCategoryBrand")
    public void addXiaomiShoujiKaCategoryBrand() throws IOException {
        MarketBrandPO queryMarketBrandPO = new MarketBrandPO();
        queryMarketBrandPO.setBrandId("754005757099245568e83100108e764f1297fc6c3c13ea2129");
        Date nowTime = new Date();
        List<MarketBrandPO> marketBrandPOS = marketBrandMapper.select(queryMarketBrandPO);
        for (MarketBrandPO marketBrandPO : marketBrandPOS) {
            String brandName = marketBrandPO.getBrandName();
            String brandId = marketBrandPO.getBrandId();
            for (int k = 1; k < BrandGoodsTypeMockData.brandmodel.length; k++) {
                if (k != 1) {
                    continue;
                }
                String categoryId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String categoryName = brandName + BrandGoodsTypeMockData.brandmodel[k];
                CategoryBrandPO categoryBrandPO = new CategoryBrandPO();
                categoryBrandPO.setCategoryId(categoryId);
                categoryBrandPO.setCategoryName(categoryName);
                categoryBrandPO.setBrandId(brandId);
                categoryBrandPO.setBrandName(brandName);
                String goodsTypeId1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String goodsTypeName1 = BrandGoodsTypeMockData.brandmodel[k];
                for (int j = 0; j < BrandGoodsTypeMockData.modelGoodsshouji1.length; j++) {
                    String goodsTypeId2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String goodsTypeName2 = BrandGoodsTypeMockData.modelGoodsshouji1[j];
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    log.info("addCategoryBrand2={}", categoryBrandPO);
                    categoryBrandMapper.insertSelective(categoryBrandPO);
                    CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                    BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                    categoryBrandDocument.setVersion("1");
                    categoryBrandDocument.setCreatedTime(nowTime);
                    categoryBrandDocument.setUpdateTime(nowTime);
                    //发送kafka
                    String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                    kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                    marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);

                }

                categoryBrandPO.setSuperiorTypeId(null);
                categoryBrandPO.setGoodsTypeId(goodsTypeId1);
                categoryBrandPO.setGoodsTypeName(goodsTypeName1);
                categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                log.info("addCategoryBrand1={}", categoryBrandPO);
                categoryBrandMapper.insertSelective(categoryBrandPO);
                CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                categoryBrandDocument.setVersion("1");
                categoryBrandDocument.setCreatedTime(nowTime);
                categoryBrandDocument.setUpdateTime(nowTime);
                //发送kafka
                String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
            }
        }

    }

    @ApiOperation("mock小米电脑品类品牌数据")
    @GetMapping("addXiaomiDiannaoCategoryBrand")
    public void addXiaomiDiannaoCategoryBrand() throws IOException {
        MarketBrandPO queryMarketBrandPO = new MarketBrandPO();
        queryMarketBrandPO.setBrandId("754005757099245568e83100108e764f1297fc6c3c13ea2129");
        List<MarketBrandPO> marketBrandPOS = marketBrandMapper.select(queryMarketBrandPO);
        Date nowTime = new Date();
        for (MarketBrandPO marketBrandPO : marketBrandPOS) {
            String brandName = marketBrandPO.getBrandName();
            String brandId = marketBrandPO.getBrandId();
            for (int k = 2; k < BrandGoodsTypeMockData.brandmodel.length; k++) {
                if (k != 2) {
                    continue;
                }
                String categoryId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String categoryName = brandName + BrandGoodsTypeMockData.brandmodel[k];
                CategoryBrandPO categoryBrandPO = new CategoryBrandPO();
                categoryBrandPO.setCategoryId(categoryId);
                categoryBrandPO.setCategoryName(categoryName);
                categoryBrandPO.setBrandId(brandId);
                categoryBrandPO.setBrandName(brandName);
                String goodsTypeId1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String goodsTypeName1 = BrandGoodsTypeMockData.brandmodel[k];
                for (int j = 0; j < BrandGoodsTypeMockData.modeldiannao1.length; j++) {
                    String goodsTypeId2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String goodsTypeName2 = BrandGoodsTypeMockData.modeldiannao1[j];
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    for (int n = 0; n < BrandGoodsTypeMockData.modeldiannao11.length; n++) {
                        String goodsTypeId3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String goodsTypeName3 = BrandGoodsTypeMockData.modeldiannao11[n];
                        categoryBrandPO.setGoodsTypeName(goodsTypeName3);
                        categoryBrandPO.setGoodsTypeId(goodsTypeId3);
                        categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                        categoryBrandPO.setSuperiorTypeId(goodsTypeId2);
                        log.info("addCategoryBrand3={}", categoryBrandPO);
                        CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                        BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                        categoryBrandDocument.setVersion("1");
                        categoryBrandDocument.setCreatedTime(nowTime);
                        categoryBrandDocument.setUpdateTime(nowTime);
                        //发送kafka
                        String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                        kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                        marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
                    }
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    log.info("addCategoryBrand2={}", categoryBrandPO);
                    CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                    BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                    categoryBrandDocument.setVersion("1");
                    categoryBrandDocument.setCreatedTime(nowTime);
                    categoryBrandDocument.setUpdateTime(nowTime);
                    //发送kafka
                    String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                    kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                    marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
                    addDianNaoGoodsDocument(categoryBrandDocument);
                }

                categoryBrandPO.setSuperiorTypeId(null);
                categoryBrandPO.setGoodsTypeId(goodsTypeId1);
                categoryBrandPO.setGoodsTypeName(goodsTypeName1);
                categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                log.info("addCategoryBrand1={}", categoryBrandPO);
                CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                categoryBrandDocument.setVersion("1");
                categoryBrandDocument.setCreatedTime(nowTime);
                categoryBrandDocument.setUpdateTime(nowTime);
//                发送kafka
                String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
            }
        }

    }

    @ApiOperation("mock小米电视品类品牌数据")
    @GetMapping("addXiaomiDianshiCategoryBrand")
    public void addXiaomiDianshiCategoryBrand() throws IOException {
        MarketBrandPO queryMarketBrandPO = new MarketBrandPO();
        queryMarketBrandPO.setBrandId("754005757099245568e83100108e764f1297fc6c3c13ea2129");
        List<MarketBrandPO> marketBrandPOS = marketBrandMapper.select(queryMarketBrandPO);
        Date nowTime = new Date();
        for (MarketBrandPO marketBrandPO : marketBrandPOS) {
            String brandName = marketBrandPO.getBrandName();
            String brandId = marketBrandPO.getBrandId();
            for (int k = 3; k < BrandGoodsTypeMockData.brandmodel.length; k++) {
                if (k != 3) {
                    continue;
                }
                String categoryId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String categoryName = brandName + BrandGoodsTypeMockData.brandmodel[k];
                CategoryBrandPO categoryBrandPO = new CategoryBrandPO();
                categoryBrandPO.setCategoryId(categoryId);
                categoryBrandPO.setCategoryName(categoryName);
                categoryBrandPO.setBrandId(brandId);
                categoryBrandPO.setBrandName(brandName);
                String goodsTypeId1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String goodsTypeName1 = BrandGoodsTypeMockData.brandmodel[k];
                for (int j = 0; j < BrandGoodsTypeMockData.modeldianshi1.length; j++) {
                    String goodsTypeId2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String goodsTypeName2 = BrandGoodsTypeMockData.modeldianshi1[j];
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    for (int n = 0; n < BrandGoodsTypeMockData.modeldianshi11.length; n++) {
                        String goodsTypeId3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String goodsTypeName3 = BrandGoodsTypeMockData.modeldianshi11[n];
                        categoryBrandPO.setGoodsTypeName(goodsTypeName3);
                        categoryBrandPO.setGoodsTypeId(goodsTypeId3);
                        categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                        categoryBrandPO.setSuperiorTypeId(goodsTypeId2);
                        log.info("addCategoryBrand3={}", categoryBrandPO);
                        CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                        BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                        categoryBrandDocument.setVersion("1");
                        categoryBrandDocument.setCreatedTime(nowTime);
                        categoryBrandDocument.setUpdateTime(nowTime);
                        //发送kafka
                        String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                        kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                        marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
                    }
                    categoryBrandPO.setGoodsTypeName(goodsTypeName2);
                    categoryBrandPO.setGoodsTypeId(goodsTypeId2);
                    categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                    categoryBrandPO.setSuperiorTypeId(goodsTypeId1);
                    log.info("addCategoryBrand2={}", categoryBrandPO);
                    CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                    BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                    categoryBrandDocument.setVersion("1");
                    categoryBrandDocument.setCreatedTime(nowTime);
                    categoryBrandDocument.setUpdateTime(nowTime);
                    //发送kafka
                    String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                    kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                    marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
                    addDianShiGoodsDocument(categoryBrandDocument);

                }


                categoryBrandPO.setSuperiorTypeId(null);
                categoryBrandPO.setGoodsTypeId(goodsTypeId1);
                categoryBrandPO.setGoodsTypeName(goodsTypeName1);
                categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                log.info("addCategoryBrand1={}", categoryBrandPO);
                CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                categoryBrandDocument.setVersion("1");
                categoryBrandDocument.setCreatedTime(nowTime);
                categoryBrandDocument.setUpdateTime(nowTime);
                //发送kafka
                String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);

            }
        }

    }

    @ApiOperation("mock小米其它品类品牌数据")
    @GetMapping("addXiaomiOtherCategoryBrand")
    public void addXiaomiOtherCategoryBrand() throws IOException {
        MarketBrandPO queryMarketBrandPO = new MarketBrandPO();
        queryMarketBrandPO.setBrandId("754005757099245568e83100108e764f1297fc6c3c13ea2129");
        Date nowTime = new Date();
        List<MarketBrandPO> marketBrandPOS = marketBrandMapper.select(queryMarketBrandPO);
        for (MarketBrandPO marketBrandPO : marketBrandPOS) {
            String brandName = marketBrandPO.getBrandName();
            String brandId = marketBrandPO.getBrandId();
            for (int k = 0; k < BrandGoodsTypeMockData.brandmodel.length; k++) {
                if (k <= 3) {
                    continue;
                }
                String categoryId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String categoryName = brandName + BrandGoodsTypeMockData.brandmodel[k];
                CategoryBrandPO categoryBrandPO = new CategoryBrandPO();
                categoryBrandPO.setCategoryId(categoryId);
                categoryBrandPO.setCategoryName(categoryName);
                categoryBrandPO.setBrandId(brandId);
                categoryBrandPO.setBrandName(brandName);
                String goodsTypeId1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String goodsTypeName1 = BrandGoodsTypeMockData.brandmodel[k];

                categoryBrandPO.setSuperiorTypeId(null);
                categoryBrandPO.setGoodsTypeId(goodsTypeId1);
                categoryBrandPO.setGoodsTypeName(goodsTypeName1);
                categoryBrandPO.setSearchHeat(SuperRandom.getNum(1, 100));
                log.info("addCategoryBrand1={}", categoryBrandPO);
                CategoryBrandDocument categoryBrandDocument = new CategoryBrandDocument();
                BeanUtils.copyProperties(categoryBrandPO, categoryBrandDocument);
                categoryBrandDocument.setVersion("1");
                categoryBrandDocument.setCreatedTime(nowTime);
                categoryBrandDocument.setUpdateTime(nowTime);
                //发送kafka
                String kafkaMessage = JSONUtil.toJsonStr(categoryBrandDocument);
                kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.CATEGORY_BRAND.getTopic(), kafkaMessage);
//                marketGoodsService.insertEs(ESIndexNameEnum.CATEGORY_BRAND.getIndexName(), categoryBrandDocument);
            }
        }

    }

    @ApiOperation("mockT恤商品数据")
    @GetMapping("addTXieMarketGoods")
    public void addTXieMarketGoods() {
        CategoryBrandPO queryCategoryBrandPO = new CategoryBrandPO();
        queryCategoryBrandPO.setCategoryId("752552954233356288a3b1f387deaf4a0b9c22681f4df7a4ed");
        List<CategoryBrandPO> categoryBrandPOS = categoryBrandMapper.select(queryCategoryBrandPO);
        for (CategoryBrandPO categoryBrandPO : categoryBrandPOS) {
            MarketGoodsType queryMarketGoodsType = new MarketGoodsType();
            queryMarketGoodsType.setBrandId(categoryBrandPO.getBrandId());
            List<MarketGoodsType> marketGoodsTypes = mongoDbService.getMarketGoodsTypes(queryMarketGoodsType);
            for (MarketGoodsType marketGoodsType : marketGoodsTypes) {
                String goodsTypeId = marketGoodsType.getGoodsTypeId();
                String[] tXieShopNames = TxieMockData.tXieShopName;
                String[] commonShopNames = MarketGoodsMockData.commonShopName;
                List<String> allShopNames = Lists.newArrayList();
                for (String tXieShopName : commonShopNames) {
                    allShopNames.add(tXieShopName);
                }
                for (String tXieShopName : tXieShopNames) {
                    allShopNames.add(tXieShopName);
                }
                //店名
                for (String tXieShopName : allShopNames) {
                    String shopId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    MarketGoodsDocument marketGoodsDocument = new MarketGoodsDocument();
                    BeanUtils.copyProperties(categoryBrandPO, marketGoodsDocument);
                    marketGoodsDocument.setGoodsTypeId(goodsTypeId);
                    marketGoodsDocument.setShopId(shopId);
                    marketGoodsDocument.setShopName(tXieShopName);
                    marketGoodsDocument.setGoodsGrade(SuperRandom.getNum(1, 3) + "");
                    marketGoodsDocument.setGoodsScoring(SuperRandom.getNum(1, 5) + "");
                    marketGoodsDocument.setShopGrade(SuperRandom.getNum(1, 3) + "");
                    marketGoodsDocument.setShopScoring(SuperRandom.getNum(1, 5) + "");
                    marketGoodsDocument.setSalesVolume(Long.valueOf(SuperRandom.getNum(1, 9999999)) + "");
                    marketGoodsDocument.setSearchHeat(Long.valueOf(SuperRandom.getNum(1, 100)) + "");
                    MarketGoodsParams marketGoodsParams = new MarketGoodsParams();
                    marketGoodsParams.setGoodsTypeId(goodsTypeId);
                    marketGoodsDocument.setGoodsTypeName(marketGoodsType.getGoodsTypeName());
                    int maxcolour = TxieMockData.colour.length;
                    for (int k = 0; k < maxcolour; k++) {
                        String PictureUrl = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramCode1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramName1 = TxieMockData.colour[k];
                        marketGoodsParams.setParamCode1(paramCode1);
                        marketGoodsParams.setParamName1(paramName1);
                        int maxxingbie = TxieMockData.xingbie.length;
                        for (int j = 0; j < maxxingbie; j++) {
                            String paramCode2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                            String paramName2 = TxieMockData.xingbie[j];
                            marketGoodsParams.setParamCode2(paramCode2);
                            marketGoodsParams.setParamName2(paramName2);
                            int maxkuanshi = TxieMockData.kuanshi.length;
                            for (int n = 0; n < maxkuanshi; n++) {
                                String paramCode3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                String paramName3 = TxieMockData.kuanshi[n];
                                marketGoodsParams.setParamCode3(paramCode3);
                                marketGoodsParams.setParamName3(paramName3);
                                int maxcailiao = TxieMockData.cailiao.length;
                                for (int m = 0; m < maxcailiao; m++) {
                                    Date nowTime = new Date();
                                    String goodsId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    marketGoodsParams.setGoodsId(goodsId);
                                    BigDecimal getPrice = SuperRandom.getPrice(1289, 99);
                                    String paramCode4 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    String paramName4 = TxieMockData.cailiao[m];
                                    String goodsName = tXieShopName + categoryBrandPO.getCategoryName() + paramName1 + paramName2 + paramName3 + paramName4;
                                    marketGoodsParams.setParamCode4(paramCode4);
                                    marketGoodsParams.setParamName4(paramName4);
                                    int num = SuperRandom.getNum(1, 29);
                                    if (num == 15) {
                                        marketGoodsParams.setIsValid("0");
                                    } else {
                                        marketGoodsParams.setIsValid("1");
                                    }
                                    marketGoodsParams.setPictureUrl("http://market/goods/" + PictureUrl + ".jpg");
                                    marketGoodsParams.setGoodsId(goodsId);
                                    marketGoodsParams.setGoodsTypeId(goodsTypeId);
                                    marketGoodsParams.setCreatedTime(nowTime);
                                    marketGoodsParams.setUpdateTime(nowTime);
                                    marketGoodsParams.setGoodsPrice(getPrice);
//                                    log.info("marketGoodsParams={}",marketGoodsParams);
                                    //发送到kafka
                                    marketGoodsDocument.setGoodsId(goodsId);
                                    marketGoodsDocument.setGoodsName(goodsName);
//                                marketGoodsDocument.setGoodsLabels(JSONUtil.toJsonStr(marketGoodsParams));
                                    marketGoodsDocument.setGoodsLabels(goodsName);
                                    marketGoodsDocument.setGoodsPrice(getPrice);
                                    marketGoodsDocument.setShopId(shopId);
                                    marketGoodsDocument.setShopName(tXieShopName);
                                    marketGoodsDocument.setVersion(1 + "");
                                    marketGoodsDocument.setCreatedTime(nowTime);
                                    marketGoodsDocument.setUpdateTime(nowTime);
                                    //发送到发送到kafka

                                    log.info("marketGoodsDocument={}", marketGoodsDocument);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    @ApiOperation("mock商品数据")
    @GetMapping("addPhoneMarketGoods")
    public void addPhoneMarketGoods() {
        CategoryBrandPO queryCategoryBrandPO = new CategoryBrandPO();
        queryCategoryBrandPO.setCategoryId("752552954233356288a3b1f387deaf4a0b9c22681f4df7a4ed");
        List<CategoryBrandPO> categoryBrandPOS = categoryBrandMapper.select(queryCategoryBrandPO);
        for (CategoryBrandPO categoryBrandPO : categoryBrandPOS) {
            MarketGoodsType queryMarketGoodsType = new MarketGoodsType();
            queryMarketGoodsType.setBrandId(categoryBrandPO.getBrandId());
            List<MarketGoodsType> marketGoodsTypes = mongoDbService.getMarketGoodsTypes(queryMarketGoodsType);
            for (MarketGoodsType marketGoodsType : marketGoodsTypes) {
                String goodsTypeId = marketGoodsType.getGoodsTypeId();
                String[] tXieShopNames = TxieMockData.tXieShopName;
                String[] commonShopNames = MarketGoodsMockData.commonShopName;
                List<String> allShopNames = Lists.newArrayList();
                for (String tXieShopName : commonShopNames) {
                    allShopNames.add(tXieShopName);
                }
                for (String tXieShopName : tXieShopNames) {
                    allShopNames.add(tXieShopName);
                }
                //店名
                for (String tXieShopName : allShopNames) {
                    String shopId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    MarketGoodsDocument marketGoodsDocument = new MarketGoodsDocument();
                    BeanUtils.copyProperties(categoryBrandPO, marketGoodsDocument);
                    marketGoodsDocument.setGoodsTypeId(goodsTypeId);
                    marketGoodsDocument.setShopId(shopId);
                    marketGoodsDocument.setShopName(tXieShopName);
                    marketGoodsDocument.setGoodsGrade(SuperRandom.getNum(1, 3) + "");
                    marketGoodsDocument.setGoodsScoring(SuperRandom.getNum(1, 5) + "");
                    marketGoodsDocument.setShopGrade(SuperRandom.getNum(1, 3) + "");
                    marketGoodsDocument.setShopScoring(SuperRandom.getNum(1, 5) + "");
                    marketGoodsDocument.setSalesVolume(Long.valueOf(SuperRandom.getNum(1, 999999999)) + "");
                    marketGoodsDocument.setSearchHeat(Long.valueOf(SuperRandom.getNum(1, 100)) + "");
                    MarketGoodsParams marketGoodsParams = new MarketGoodsParams();
                    marketGoodsParams.setGoodsTypeId(goodsTypeId);
                    marketGoodsDocument.setGoodsTypeName(marketGoodsType.getGoodsTypeName());
                    int maxcolour = TxieMockData.colour.length;
                    for (int k = 0; k < maxcolour; k++) {
                        String PictureUrl = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramCode1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramName1 = TxieMockData.colour[k];
                        marketGoodsParams.setParamCode1(paramCode1);
                        marketGoodsParams.setParamName1(paramName1);
                        int maxxingbie = TxieMockData.xingbie.length;
                        for (int j = 0; j < maxxingbie; j++) {
                            String paramCode2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                            String paramName2 = TxieMockData.xingbie[j];
                            marketGoodsParams.setParamCode2(paramCode2);
                            marketGoodsParams.setParamName2(paramName2);
                            int maxkuanshi = TxieMockData.kuanshi.length;
                            for (int n = 0; n < maxkuanshi; n++) {
                                String paramCode3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                String paramName3 = TxieMockData.kuanshi[n];
                                marketGoodsParams.setParamCode3(paramCode3);
                                marketGoodsParams.setParamName3(paramName3);
                                int maxcailiao = TxieMockData.cailiao.length;
                                for (int m = 0; m < maxcailiao; m++) {
                                    Date nowTime = new Date();
                                    String goodsId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    marketGoodsParams.setGoodsId(goodsId);
                                    BigDecimal getPrice = SuperRandom.getPrice(1289, 99);
                                    String paramCode4 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    String paramName4 = TxieMockData.cailiao[m];
                                    String goodsName = tXieShopName + categoryBrandPO.getCategoryName() + paramName1 + paramName2 + paramName3 + paramName4;
                                    marketGoodsParams.setParamCode4(paramCode4);
                                    marketGoodsParams.setParamName4(paramName4);
                                    int num = SuperRandom.getNum(1, 29);
                                    if (num == 15) {
                                        marketGoodsParams.setIsValid("0");
                                    } else {
                                        marketGoodsParams.setIsValid("1");
                                    }
                                    marketGoodsParams.setPictureUrl("http://market/goods/" + PictureUrl + ".jpg");
                                    marketGoodsParams.setGoodsId(goodsId);
                                    marketGoodsParams.setGoodsTypeId(goodsTypeId);
                                    marketGoodsParams.setCreatedTime(nowTime);
                                    marketGoodsParams.setUpdateTime(nowTime);
                                    marketGoodsParams.setGoodsPrice(getPrice);
//                                    log.info("marketGoodsParams={}",marketGoodsParams);
                                    //发送到kafka
                                    marketGoodsDocument.setGoodsId(goodsId);
                                    marketGoodsDocument.setGoodsName(goodsName);
//                                marketGoodsDocument.setGoodsLabels(JSONUtil.toJsonStr(marketGoodsParams));
                                    marketGoodsDocument.setGoodsLabels(goodsName);
                                    marketGoodsDocument.setGoodsPrice(getPrice);
                                    marketGoodsDocument.setShopId(shopId);
                                    marketGoodsDocument.setShopName(tXieShopName);
                                    marketGoodsDocument.setVersion(1 + "");
                                    marketGoodsDocument.setCreatedTime(nowTime);
                                    marketGoodsDocument.setUpdateTime(nowTime);
                                    //发送到发送到kafka

                                    log.info("marketGoodsDocument={}", marketGoodsDocument);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private void addPhoneGoodsDocument(CategoryBrandDocument categoryBrandDocument) throws IOException {
        String goodsTypeId = categoryBrandDocument.getGoodsTypeId();
        String categoryName = categoryBrandDocument.getCategoryName();
        String goodsTypeName = categoryBrandDocument.getGoodsTypeName();
        String[] tXieShopNames = PhoneMockData.phoneShopName;
        String[] commonShopNames = MarketGoodsMockData.commonShopName;
        List<String> allShopNames = Lists.newArrayList();
        for (String tXieShopName : commonShopNames) {
            allShopNames.add(tXieShopName);
        }
        for (String tXieShopName : tXieShopNames) {
            allShopNames.add(tXieShopName);
        }
        //店名
        for (String phoneShopName : allShopNames) {
            String shopId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
            MarketGoodsDocument marketGoodsDocument = new MarketGoodsDocument();
            BeanUtils.copyProperties(categoryBrandDocument, marketGoodsDocument);
            //纬度
            int latitudeZhengshu = (int) (Math.random() * (53 - 3 + 1) + 3);
            int latitudeXiaoshu = (int) (Math.random() * (100 - 0 + 1) + 0);
            //经度
            int longitudeZhengshu = (int) (Math.random() * (135 - 73 + 1) + 73);
            int longitudeXiaoshu = (int) (Math.random() * (100 - 0 + 1) + 0);
            Location location = new Location();
            String longitude = longitudeZhengshu + "." + longitudeXiaoshu;
            String latitude = latitudeZhengshu + "." + latitudeXiaoshu;
            location.setLat(new BigDecimal(latitude));
            location.setLon(new BigDecimal(longitude));
            marketGoodsDocument.setLocation(location);
            marketGoodsDocument.setShopId(shopId);
            marketGoodsDocument.setShopName(phoneShopName);
            marketGoodsDocument.setShopGrade(SuperRandom.getNum(1, 3) + "");
            marketGoodsDocument.setShopScoring(SuperRandom.getNum(1, 5) + "");
            MarketGoodsParams marketGoodsParams = new MarketGoodsParams();
            marketGoodsParams.setGoodsTypeId(goodsTypeId);
            int maxcolour = PhoneMockData.colour.length;
            for (int k = 0; k < maxcolour; k++) {
                String PictureUrl = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String paramCode1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String paramName1 = PhoneMockData.colour[k];
                marketGoodsParams.setParamCode1(paramCode1);
                marketGoodsParams.setParamName1(paramName1);
                int maxcunChu = PhoneMockData.cunChu.length;
                for (int j = 0; j < maxcunChu; j++) {
                    String paramCode2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String paramName2 = PhoneMockData.cunChu[j];
                    marketGoodsParams.setParamCode2(paramCode2);
                    marketGoodsParams.setParamName2(paramName2);
                    int maxneicum = PhoneMockData.neicum.length;
                    for (int n = 0; n < maxneicum; n++) {
                        String paramCode3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramName3 = PhoneMockData.neicum[n];
                        marketGoodsParams.setParamCode3(paramCode3);
                        marketGoodsParams.setParamName3(paramName3);
                        int maxbanben = PhoneMockData.banben.length;
                        for (int m = 0; m < maxbanben; m++) {
                            Date nowTime = new Date();
                            String goodsId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                            marketGoodsParams.setGoodsId(goodsId);
                            BigDecimal getPrice = SuperRandom.getPrice(1289, 99);
                            String paramCode4 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                            String paramName4 = PhoneMockData.banben[m];
                            String goodsName = goodsTypeName + paramName1 + paramName2 + paramName3 + paramName4;
                            marketGoodsParams.setParamCode4(paramCode4);
                            marketGoodsParams.setParamName4(paramName4);
                            int num = SuperRandom.getNum(1, 29);
                            if (num == 15) {
                                marketGoodsParams.setIsValid("0");
                            } else {
                                marketGoodsParams.setIsValid("1");
                            }
                            marketGoodsParams.setPictureUrl("http://market/goods/" + PictureUrl + ".jpg");
                            marketGoodsParams.setGoodsId(goodsId);
                            marketGoodsParams.setGoodsTypeId(goodsTypeId);
                            marketGoodsParams.setCreatedTime(nowTime);
                            marketGoodsParams.setUpdateTime(nowTime);
                            marketGoodsParams.setGoodsPrice(getPrice);
//                                    log.info("marketGoodsParams={}",marketGoodsParams);
                            //发送到kafka
                            marketGoodsDocument.setGoodsId(goodsId);
                            marketGoodsDocument.setGoodsName(goodsName);
//                                marketGoodsDocument.setGoodsLabels(JSONUtil.toJsonStr(marketGoodsParams));
                            marketGoodsDocument.setGoodsLabels(goodsName);
                            marketGoodsDocument.setGoodsPrice(getPrice);
                            marketGoodsDocument.setShopId(shopId);
                            marketGoodsDocument.setShopName(phoneShopName);
                            marketGoodsDocument.setGoodsGrade(SuperRandom.getNum(1, 3) + "");
                            marketGoodsDocument.setGoodsScoring(SuperRandom.getNum(1, 5) + "");
                            marketGoodsDocument.setSalesVolume(Long.valueOf(SuperRandom.getNum(1, 999999999)) + "");
                            marketGoodsDocument.setSearchHeat(Long.valueOf(SuperRandom.getNum(1, 100)) + "");

//                            log.info("marketGoodsDocument={}", marketGoodsDocument);

                            //发送到发送到kafka
                            String marketGoodsParamsKafkaMessage = JSONUtil.toJsonStr(marketGoodsParams);
                            kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.MARKET_GOODS_PARAMS.getTopic(), marketGoodsParamsKafkaMessage);
                            String marketGoodsDocKafkaMessage = JSONUtil.toJsonStr(marketGoodsDocument);
                            kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.MARKETGOODS.getTopic(), marketGoodsDocKafkaMessage);
//                            marketGoodsService.insertEs(ESIndexNameEnum.MARKET_GOODS.getIndexName(), marketGoodsDocument);
                        }
                    }
                }
            }
        }
    }

    private void addDianNaoGoodsDocument(CategoryBrandDocument categoryBrandDocument) throws IOException {
        String goodsTypeId = categoryBrandDocument.getGoodsTypeId();
        String categoryName = categoryBrandDocument.getCategoryName();
        String goodsTypeName = categoryBrandDocument.getGoodsTypeName();
        String[] tXieShopNames = DiannaoMockData.diannaoShopName;
        String[] commonShopNames = MarketGoodsMockData.commonShopName;
        List<String> allShopNames = Lists.newArrayList();
        for (String tXieShopName : commonShopNames) {
            allShopNames.add(tXieShopName);
        }
        for (String tXieShopName : tXieShopNames) {
            allShopNames.add(tXieShopName);
        }
        //店名
        for (String diannaoShopName : allShopNames) {
            String shopId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
            MarketGoodsDocument marketGoodsDocument = new MarketGoodsDocument();
            BeanUtils.copyProperties(categoryBrandDocument, marketGoodsDocument);
            //纬度
            int latitudeZhengshu = (int) (Math.random() * (53 - 3 + 1) + 3);
            int latitudeXiaoshu = (int) (Math.random() * (100 - 0 + 1) + 0);
            //经度
            int longitudeZhengshu = (int) (Math.random() * (135 - 73 + 1) + 73);
            int longitudeXiaoshu = (int) (Math.random() * (100 - 0 + 1) + 0);
            Location location = new Location();
            String longitude = longitudeZhengshu + "." + longitudeXiaoshu;
            String latitude = latitudeZhengshu + "." + latitudeXiaoshu;
            location.setLat(new BigDecimal(latitude));
            location.setLon(new BigDecimal(longitude));
            marketGoodsDocument.setLocation(location);
            marketGoodsDocument.setShopId(shopId);
            marketGoodsDocument.setShopName(diannaoShopName);
            marketGoodsDocument.setShopGrade(SuperRandom.getNum(1, 3) + "");
            marketGoodsDocument.setShopScoring(SuperRandom.getNum(1, 5) + "");
            MarketGoodsParams marketGoodsParams = new MarketGoodsParams();
            marketGoodsParams.setGoodsTypeId(goodsTypeId);
            int maxcolour = DiannaoMockData.colour.length;
            for (int k = 0; k < maxcolour; k++) {
                String PictureUrl = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String paramCode1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String paramName1 = DiannaoMockData.colour[k];
                marketGoodsParams.setParamCode1(paramCode1);
                marketGoodsParams.setParamName1(paramName1);
                int maxcpu = DiannaoMockData.cpu.length;
                for (int j = 0; j < maxcpu; j++) {
                    String paramCode2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String paramName2 = DiannaoMockData.cpu[j];
                    marketGoodsParams.setParamCode2(paramCode2);
                    marketGoodsParams.setParamName2(paramName2);
                    int maxxianshipingcun = DiannaoMockData.xianshipingcun.length;
                    for (int n = 0; n < maxxianshipingcun; n++) {
                        String paramCode3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramName3 = DiannaoMockData.xianshipingcun[n];
                        marketGoodsParams.setParamCode3(paramCode3);
                        marketGoodsParams.setParamName3(paramName3);
                        int maxneicun = DiannaoMockData.neicun.length;
                        for (int m = 0; m < maxneicun; m++) {
                            String paramCode4 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                            String paramName4 = DiannaoMockData.neicun[m];
                            marketGoodsParams.setParamCode4(paramCode4);
                            marketGoodsParams.setParamName4(paramName4);
                            int maxyingpang = DiannaoMockData.yingpang.length;
                            for (int a = 0; a < maxyingpang; a++) {
                                String paramCode5 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                String paramName5 = DiannaoMockData.yingpang[a];
                                marketGoodsParams.setParamCode5(paramCode5);
                                marketGoodsParams.setParamName5(paramName5);
                                int maxduxian = DiannaoMockData.duxian.length;
                                for (int b = 0; b < maxduxian; b++) {
                                    String paramCode6 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    String paramName6 = DiannaoMockData.duxian[b];
                                    marketGoodsParams.setParamCode6(paramCode6);
                                    marketGoodsParams.setParamName6(paramName6);
                                    int maxxianshipingcailiao = DiannaoMockData.xianshipingcailiao.length;
                                    for (int c = 0; c < maxxianshipingcailiao; c++) {
                                        String paramCode7 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                        String paramName7 = DiannaoMockData.xianshipingcailiao[c];
                                        marketGoodsParams.setParamCode7(paramCode7);
                                        marketGoodsParams.setParamName7(paramName7);
                                        int maxbanben = DiannaoMockData.banben.length;
                                        for (int d = 0; d < maxbanben; d++) {
                                            String paramCode8 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                            String paramName8 = DiannaoMockData.banben[d];
                                            marketGoodsParams.setParamCode8(paramCode8);
                                            marketGoodsParams.setParamName8(paramName8);
                                            Date nowTime = new Date();
                                            String goodsId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                            String goodsName = goodsTypeName + paramName1 + paramName2 + paramName3 + paramName4 + paramName5 + paramName6 + paramName7 + paramName8;
                                            marketGoodsParams.setGoodsId(goodsId);
                                            BigDecimal getPrice = SuperRandom.getPrice(1289, 99);
                                            int num = SuperRandom.getNum(1, 29);
                                            if (num == 15) {
                                                marketGoodsParams.setIsValid("0");
                                            } else {
                                                marketGoodsParams.setIsValid("1");
                                            }
                                            marketGoodsParams.setPictureUrl("http://market/goods/" + PictureUrl + ".jpg");
                                            marketGoodsParams.setGoodsId(goodsId);
                                            marketGoodsParams.setGoodsTypeId(goodsTypeId);
                                            marketGoodsParams.setCreatedTime(nowTime);
                                            marketGoodsParams.setUpdateTime(nowTime);
                                            marketGoodsParams.setGoodsPrice(getPrice);

                                            marketGoodsDocument.setGoodsId(goodsId);
                                            marketGoodsDocument.setGoodsName(goodsName);
                                            marketGoodsDocument.setCategoryName(categoryName);
                                            //                                marketGoodsDocument.setGoodsLabels(JSONUtil.toJsonStr(marketGoodsParams));
                                            marketGoodsDocument.setGoodsLabels(goodsName);
                                            marketGoodsDocument.setGoodsPrice(getPrice);
                                            marketGoodsDocument.setShopId(shopId);
                                            marketGoodsDocument.setShopName(diannaoShopName);
                                            marketGoodsDocument.setGoodsGrade(SuperRandom.getNum(1, 3) + "");
                                            marketGoodsDocument.setGoodsScoring(SuperRandom.getNum(1, 5) + "");
                                            marketGoodsDocument.setSalesVolume(Long.valueOf(SuperRandom.getNum(1, 999999999)) + "");
                                            marketGoodsDocument.setSearchHeat(Long.valueOf(SuperRandom.getNum(1, 100)) + "");
                                            //发送到发送到kafka

//                                            log.info("marketGoodsDocument={}", marketGoodsDocument);
                                            String marketGoodsParamsKafkaMessage = JSONUtil.toJsonStr(marketGoodsParams);
                                            kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.MARKET_GOODS_PARAMS.getTopic(), marketGoodsParamsKafkaMessage);
                                            String marketGoodsDocKafkaMessage = JSONUtil.toJsonStr(marketGoodsDocument);
                                            kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.MARKETGOODS.getTopic(), marketGoodsDocKafkaMessage);
//                                            marketGoodsService.insertEs(ESIndexNameEnum.MARKET_GOODS.getIndexName(), marketGoodsDocument);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }


    private void addDianShiGoodsDocument(CategoryBrandDocument categoryBrandDocument) throws IOException {
        String goodsTypeId = categoryBrandDocument.getGoodsTypeId();
        String categoryName = categoryBrandDocument.getCategoryName();
        String goodsTypeName = categoryBrandDocument.getGoodsTypeName();
        String[] tXieShopNames = DianShiMockData.dianshiShopName;
        String[] commonShopNames = MarketGoodsMockData.commonShopName;
        List<String> allShopNames = Lists.newArrayList();
        for (String tXieShopName : commonShopNames) {
            allShopNames.add(tXieShopName);
        }
        for (String tXieShopName : tXieShopNames) {
            allShopNames.add(tXieShopName);
        }
        //店名
        for (String dianshiShopName : allShopNames) {
            String shopId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
            MarketGoodsDocument marketGoodsDocument = new MarketGoodsDocument();
            BeanUtils.copyProperties(categoryBrandDocument, marketGoodsDocument);
            //纬度
            int latitudeZhengshu = (int) (Math.random() * (53 - 3 + 1) + 3);
            int latitudeXiaoshu = (int) (Math.random() * (100 - 0 + 1) + 0);
            //经度
            int longitudeZhengshu = (int) (Math.random() * (135 - 73 + 1) + 73);
            int longitudeXiaoshu = (int) (Math.random() * (100 - 0 + 1) + 0);
            Location location = new Location();
            String longitude = longitudeZhengshu + "." + longitudeXiaoshu;
            String latitude = latitudeZhengshu + "." + latitudeXiaoshu;
            location.setLat(new BigDecimal(latitude));
            location.setLon(new BigDecimal(longitude));
            marketGoodsDocument.setLocation(location);
            marketGoodsDocument.setShopId(shopId);
            marketGoodsDocument.setShopName(dianshiShopName);
            marketGoodsDocument.setShopGrade(SuperRandom.getNum(1, 3) + "");
            marketGoodsDocument.setShopScoring(SuperRandom.getNum(1, 5) + "");
            MarketGoodsParams marketGoodsParams = new MarketGoodsParams();
            marketGoodsParams.setGoodsTypeId(goodsTypeId);
            int maxcolour = DianShiMockData.colour.length;
            for (int k = 0; k < maxcolour; k++) {
                String PictureUrl = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String paramCode1 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                String paramName1 = DianShiMockData.colour[k];
                marketGoodsParams.setParamCode1(paramCode1);
                marketGoodsParams.setParamName1(paramName1);
                int maxchicun = DianShiMockData.chicun.length;
                for (int j = 0; j < maxchicun; j++) {
                    String paramCode2 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                    String paramName2 = DianShiMockData.chicun[j];
                    marketGoodsParams.setParamCode2(paramCode2);
                    marketGoodsParams.setParamName2(paramName2);
                    int maxneicun = DianShiMockData.neicun.length;
                    for (int n = 0; n < maxneicun; n++) {
                        String paramCode3 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                        String paramName3 = DianShiMockData.neicun[n];
                        marketGoodsParams.setParamCode3(paramCode3);
                        marketGoodsParams.setParamName3(paramName3);
                        int maxyingpang = DianShiMockData.yingpang.length;
                        for (int m = 0; m < maxyingpang; m++) {
                            String paramCode4 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                            String paramName4 = DianShiMockData.yingpang[m];
                            marketGoodsParams.setParamCode4(paramCode4);
                            marketGoodsParams.setParamName4(paramName4);
                            int maxxianshipingcailiao = DianShiMockData.xianshipingcailiao.length;
                            for (int a = 0; a < maxxianshipingcailiao; a++) {
                                String paramCode5 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                String paramName5 = DianShiMockData.xianshipingcailiao[a];
                                marketGoodsParams.setParamCode5(paramCode5);
                                marketGoodsParams.setParamName5(paramName5);
                                int maxbanben = DianShiMockData.banben.length;
                                for (int b = 0; b < maxbanben; b++) {
                                    String paramCode6 = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    String paramName6 = DianShiMockData.banben[b];
                                    marketGoodsParams.setParamCode6(paramCode6);
                                    marketGoodsParams.setParamName6(paramName6);
                                    Date nowTime = new Date();
                                    String goodsId = SuperRandom.idWorker.nextId() + UUID.randomUUID().toString().replace("-", "");
                                    String goodsName = goodsTypeName + paramName1 + paramName2 + paramName3 + paramName4 + paramName5 + paramName6;
                                    marketGoodsParams.setGoodsId(goodsId);
                                    BigDecimal getPrice = SuperRandom.getPrice(1289, 99);
                                    int num = SuperRandom.getNum(1, 29);
                                    if (num == 15 || num == 19 || num == 27) {
                                        marketGoodsParams.setIsValid("0");
                                    } else {
                                        marketGoodsParams.setIsValid("1");
                                    }
                                    marketGoodsParams.setPictureUrl("http://market/goods/" + PictureUrl + ".jpg");
                                    marketGoodsParams.setGoodsId(goodsId);
                                    marketGoodsParams.setGoodsTypeId(goodsTypeId);
                                    marketGoodsParams.setCreatedTime(nowTime);
                                    marketGoodsParams.setUpdateTime(nowTime);
                                    marketGoodsParams.setGoodsPrice(getPrice);
//                                    log.info("marketGoodsParams={}", marketGoodsParams);

                                    marketGoodsDocument.setGoodsId(goodsId);
                                    marketGoodsDocument.setGoodsName(goodsName);
                                    marketGoodsDocument.setGoodsLabels(goodsName);
                                    marketGoodsDocument.setGoodsPrice(getPrice);
                                    marketGoodsDocument.setShopId(shopId);
                                    marketGoodsDocument.setShopName(dianshiShopName);
                                    marketGoodsDocument.setGoodsGrade(SuperRandom.getNum(1, 3) + "");
                                    marketGoodsDocument.setGoodsScoring(SuperRandom.getNum(1, 5) + "");
                                    marketGoodsDocument.setSalesVolume(Long.valueOf(SuperRandom.getNum(1, 999999999)) + "");
                                    marketGoodsDocument.setSearchHeat(Long.valueOf(SuperRandom.getNum(1, 100)) + "");
                                    //发送到发送到kafka

//                                    log.info("marketGoodsDocument={}", marketGoodsDocument);
                                    String marketGoodsParamsKafkaMessage = JSONUtil.toJsonStr(marketGoodsParams);
                                    kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.MARKET_GOODS_PARAMS.getTopic(), marketGoodsParamsKafkaMessage);
                                    String marketGoodsDocKafkaMessage = JSONUtil.toJsonStr(marketGoodsDocument);
                                    kafkaClusterProducer.sendToKafkaStandardMessageAsync(TopicsEnum.MARKETGOODS.getTopic(), marketGoodsDocKafkaMessage);
//                                    marketGoodsService.insertEs(ESIndexNameEnum.MARKET_GOODS.getIndexName(), marketGoodsDocument);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

}
